<!DOCTYPE html>  
<html lang="en">  
<head>  
    <meta charset="UTF-8">  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <title>登录与注册导航</title>  
    <style>  
        body {  
            font-family: Arial, sans-serif;  
            display: flex;  
            flex-direction: column;  
            align-items: center;  
            justify-content: center;  
            height: 100vh;  
            margin: 0;  
            background-color: #f4f4f4;  
        }  
  
        h2 {  
            color: #333;  
            margin-bottom: 20px;  
        }  
  
        button {  
        	margin: 10px 0;
            padding: 10px 20px;  
            font-size: 16px;  
            color: white;  
            background-color: #007BFF; 
            border: none;  
            border-radius: 5px;  
            cursor: pointer;  
            transition: background-color 0.3s ease;  
        }  
  
        button:hover {  
            background-color: #0056b3; 
        }  
  
        .container {  
            text-align: center;  
            width: 100%;  
            max-width: 400px;  
        }  
  
    </style>
    <script type="text/javascript" src="static/js/jquery-3.6.0.min.js" ></script>
</head>  
<body>  
  
	<h2>欢迎开始JavaEE技术的拦截器实验</h2>  
	<h2 id="user" style="display:none;"></h2>
	<button onclick="goToLogin()">登录</button>  
	 
	<button onclick="goToRegister()">注册</button>  
  	
  	<button onclick="goToVIP()">VIP通道</button>

	<button onclick="goToPage()">普通通道</button>

	<script>
	   var email = null;
		(function(){
			 var cookies = document.cookie.split(";");
			 console.info(cookies[0]);
			 console.info(cookies);
			 cookies.forEach((cookie)=>{
				 if(cookie.startsWith("username=") ){
					 var email = cookie.split("=")[1];
					 document.getElementById("user").style.display = "block";
					 document.getElementById("user").innerText = email;
				 }
			 })
		})();
	    function goToLogin() {  
	        window.location.href = 'static/login.html';
	    }  
	  
	    function goToRegister() {  
	        window.location.href = 'static/register.html';
	    }  
	    
	    function goToVIP(){
			$.ajax({
				type:"get",
				url:"/experiment05/user/vippage",
				success:function(data){
					if(data.code == "10000") {
						 alert("欢迎尊贵的VIP莅临");
					} else{
						alert(data.msg);
					}
				}
			})
	    }

	    function goToPage(){
			$.ajax({
				type:"get",
				url:"/experiment05/user/page",
				success:function(data){
					if(data.code == "10000") {
						 alert("欢迎光临");
					} else{
						alert(data.msg);
					}
				}
			})
	    }
	</script>  
  
</body>  
</html>